$(function () {
    addInvoice = {};

    addInvoice.get = function () {
        return {
            Type: ($(".shop-invoice-type .shop-item-s").index() - 1),
            Title: ($(".shop-invoice-title .shop-item-s input").val()),
            TaxplayerCode: parseInt($(".shop-taxpayer-identification-code-in input").val()),
            ContentType: ($(".shop-invoice-content .shop-item-s").index() - 1),
            ReceivePhone: parseInt($(".shop-invoice-phone input").val()),
            ReceiveMail: ($(".shop-invoice-mailbox input").val()),
        }


    }



    // 验证表单
    addInvoice.verificationForm = function(){
        data = addInvoice.get()
        // 发票类型
        data["Type"] == 1 || data["Type"] == 0?$(".shop-invoice-type-reminder").hide():$(".shop-invoice-type-reminder").show();
        // 发票抬头
        if(data["Title"] == "请填写个人发票抬头" || data["Title"] == undefined || data["Title"] == "请填写公司发票抬头"){
            $(".shop-invoice-title-reminder").show();
        }else{
            $(".shop-invoice-title-reminder").hide();
        }
        // 纳税人识别码
        console.log();
        
        
        if(String(data["TaxplayerCode"]) == "NaN"){
            $(".shop-taxpayer-identification-code-reminder").show();
        }else{
            $(".shop-taxpayer-identification-code-reminder").hide();
        }
        // 电话号码
        if(/^1[34578]\d{9}$/.test(data["ReceivePhone"])){
            $(".shop-invoice-phone-reminder").hide();
        }else{
            $(".shop-invoice-phone-reminder").show();
        }
    }



    function choose(th) {
        th.siblings().each(function () {
            $(this).removeClass("shop-selected");
        });
        th.addClass("shop-selected");
    }

    $(".shop-invoice-type div").on("click", function () {
        choose($(this));
        console.log($(this))
    });

    $(".shop-invoice-content .shop-right div").on("click", function () {
        choose($(this));
        console.log($(this))
    });

    // 发票抬头选中
    $(".company-invoice").on("click", function () {

    });
});
// 页面输入
function formItemInput(a, b) {
    a.on("focus", function () {
        if ($(this).val() == b) {
            $(this).val("")
        }
    });
    a.on("focusout", function () {
        if ($(this).val() == "") {
            $(this).val(b)
        }
    });

}

formItemInput($(".shop-invoice-title .shop-invoice-title-top input"), "请填写个人发票抬头");
formItemInput($(".shop-invoice-title .shop-invoice-title-bottom input"), "请填写公司发票抬头");

// 换开发票页面表单单选
$(".shop-change-invoice-form").on("click", ".shop-form-item", function () {
    
    $(this).parents("div").eq(0).find(".shop-form-item").removeClass("shop-item-s");
    $(this).toggleClass("shop-item-s");
    hideTaxpayerCode();
});

// 判断是否隐藏纳税人识别码
function hideTaxpayerCode(a) {
    if ($(".shop-item-s").parents(".shop-invoice-title-bottom").length == 1) {
        $(".shop-taxpayer-identification-code").css("display", "block")
    } else {
        $(".shop-taxpayer-identification-code").css("display", "none")
    }
}

// 获取发票抬头类型
function getInvoiceHeaderType() {
    var dp = $(".shop-taxpayer-identification-code").css("display")
    if (dp == "block") {
        return 1;
    } else if (dp == "none") {
        return 0;
    }
}



// using PPM.VerticalSite.Domain.AggregateModels.ProductAggregate;
// using PPM.VerticalSite.Domain.AggregateModels.UserAggregate;
// using PPM.VerticalSite.Domain.Seedwork;
// using System;

// namespace PPM.VerticalSite.Domain.AggregateModels.OrderAggregate {
//     /// <summary>
//     /// 发票
//     /// </summary>
//     public class Invoice: Entity, IAggregateRoot
//     {
//         public Invoice()
//         {
//             CreateDate = DateTime.Now;
//         }
//         /// <summary>
//         /// 交易id
//         /// </summary>
//         public long TraceId { get; set; }
//         /// <summary>
//         /// 用户id
//         /// </summary>
//         public long UserId { get; set; }
//         /// <summary>
//         /// 店铺id
//         /// </summary>
//         public long ShopId { get; set; }
//         /// <summary>
//         /// 发票抬头
//         /// </summary>
//         public string Title { get; set; }
//         /// <summary>
//         /// 纳税人识别码
//         /// </summary>
//         public string TaxplayerCode { get; set; }
//         /// <summary>
//         /// 发票类型
//         /// </summary>
//         public InvoiceTypeEnum Type { get; set; }
//         /// <summary>
//         /// 收票人手机
//         /// </summary>
//         public string ReceivePhone { get; set; }
//         /// <summary>
//         /// 收票人邮箱
//         /// </summary>
//         public string ReceiveMail { get; set; }
//         /// <summary>
//         /// 发票内容
//         /// </summary>
//         public InvoiceContentEnum ContentType { get; set; }
//         /// <summary>
//         ///  增票信息
//         /// </summary>
//         public string AddedInfo { get; set; }
//         /// <summary>
//         /// 创建时间
//         /// </summary>
//         public DateTime CreateDate { get; set; }
//         /// <summary>
//         /// 发票状态
//         /// </summary>
//         public InvoiceStateEnum State { get; set; }
//         /// <summary>
//         ///  备注
//         /// </summary>
//         public string Memo { get; set; }

//         public virtual User User { get; set; }
//     }
// }